{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="user_name" class="layui-input search" name="user_name" value="" placeholder="帖子内容"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="username" class="layui-input search" name="username" value="" placeholder="发布用户|用户电话"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <select name="t_status" lay-search="">
                                <option value="">不限状态</option>
                                <option value="1">正常</option>
                                <option value="2">冻结</option>
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <select name="t_fid" lay-search="">
                                <option value="">不限足球篮球</option>
                                <option value="1">足球</option>
                                <option value="2">篮球</option>
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <select name="t_type" lay-search="">
                                <option value="">不限帖子类型</option>
                                <option value="1">图文</option>
                                <option value="2">视频</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--图片显示模板-->
                    <script type="text/html" id="imgTpl">
                        {{# if(d.t_type == 1){ }}
                        {{# if(d.t_image != ''){ }}
                        <ul class="aaasss">

                            {{#  layui.each(d.t_image, function(index, item){ }}
                            <img src="{{item}}" data-original="{{item}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                            {{#  }); }}
                        </ul>
                        {{# }else{ }}
                        未配图
                        {{# } }}
                        {{# }else{ }}
                        <a href="{{d.t_image}}" target="_blank" style="color: cornflowerblue;">点击查看视频</a>
                        {{# } }}
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="t_fid">
                    {{# if(d.t_fid == 1){ }}
                    足球
                    {{# } }}
                    {{# if(d.t_fid == 2){ }}
                    篮球
                    {{# } }}
                    </script>
                    <script type="text/html" id="t_type">
                    {{# if(d.t_type == 1){ }}
                    图文
                    {{# } }}
                    {{# if(d.t_type == 2){ }}
                    视频
                    {{# } }}
                    </script>
                    <script type="text/html" id="t_status">
                    {{# if(d.t_status == 1){ }}
                    正常
                    {{# } }}
                    {{# if(d.t_status == 2){ }}
                    冻结
                    {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('查看评论', '{:url('dynComment')}?new_id={{d.t_id}}')" class="btn btn-primary btn-xs m-r-xs" title="查看评论">查看评论</a>
                        {{# if(d.t_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.t_id}}','{:url('newDown')}','确定下架吗?')" class="btn btn-primary btn-xs m-r-xs" title="下架">下架</a>
                        {{# } }}
                        {{# if(d.t_status == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.t_id}}','{:url('newUp')}','确定上架吗?')" class="btn btn-danger btn-xs m-r-xs" title="上架">上架</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.t_id}}','{:url('newDel')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Talks/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left'}
                  {type:'numbers', width: 70, title: '序号'}
                , {field: 't_content', width: '', title: '帖子内容', align: 'center'}
                , {field: 'user_username', width: 90, title: '发布用户', align: 'center'}
                , {field: 'user_phone', width: '', title: '用户电话', align: 'center'}
                , {field: 't_fid', width: 90, title: '帖子分类', align: 'center',templet: '#t_fid'}
                , {field: 't_type', width: '90', title: '内容类型', align: 'center',templet: '#t_type'}
                , {field: 't_image', width: '', title: '图片/视频', align: 'center',templet: '#imgTpl'}
                , {field: 't_comment', width: '100', title: '评论数',sort: true, align: 'center'}
                , {field: 't_zan', width: '90', title: '赞数', sort: true,align: 'center'}
                , {field: 't_status', width: '80', title: '状态', align: 'center',templet: '#t_status'}
                , {field: 't_time', width: '100', title: '发布时间', align: 'center'}
                , {fixed: 'right', width:200, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.aaasss').viewer({
                    url: 'data-original'
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAllNoSelect($('#allidsForOut').val(),$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>